import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:xihuwenti_tickets/net/api.dart';
import 'package:xihuwenti_tickets/ui/select_site_page.dart';
import 'package:xihuwenti_tickets/viewmodel/get_place_view_model.dart';

class SelectVenuePage extends BaseStatefulMvvmWidget {
  @override
  State<StatefulWidget> createState() => _SelectVenueState();
}

class _SelectVenueState
    extends BaseMvvmState<GetPlaceViewModel, SelectVenuePage> {
  @override
  Widget buildLoadingContentView() {
    return ListView.builder(
      itemBuilder: (context, index) {
        var item = viewModel.list[index];
        return Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            ImageLoad(
              "${Api.base_url}${item.imageUrl}",
              width: 100.fw(),
              height: 100.fw(),
              fit: BoxFit.cover,
            ),
            Container(width: 20,),
            CommonText(item.name,fontWeight: FontWeight.bold,textSize: 15.fs())
          ],
        ).addToContainer(
            color: Colors.white,
            padding:
                EdgeInsets.symmetric(horizontal: 16.fw(), vertical: 10.fw()))
        .onTap(() {
          viewModel.getDetail(item.id);
        });
      },
      itemCount: viewModel.list.length,
    );
  }

  @override
  GetPlaceViewModel createViewModel() {
    return GetPlaceViewModel(context);
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: CommonAppBar("选择场馆", fontSize: 17.fs()),
      body: loadingContentWidget,
    );
  }

  @override
  void onRetryClick() {
    // TODO: implement onRetryClick
  }
}
